<template>
	<view class="wrap">
		<u-input v-model="name"  maxlength="10"/>
		<u-button :type="init?'primary':''" @tap="set">确定</u-button>
		<u-toast ref="uToast" />
	</view>
</template> 
<script>
	export default {
		data() {
			return { 
				name: uni.getStorageSync('nickName') || '',
				init:false,
			}
		},
		created() {
			 
		},
		watch:{
			name(nv,oldv){
				console.log("nv,oldv: ",nv,oldv); 
				this.init = nv.trim().length > 1		 
			}
		},
		methods: {
			 set(){
			 	 if(this.name.trim().length < 1 ){
					 return this.$refs.uToast.show({ title: '昵称不能为空', type: 'info',  })
				 }
				 
			 }
		}
	}
</script>

<style lang="scss" scoped>
	.wrap {
		padding: 40rpx;
	}

	.u-avatar-wrap {
		margin-top: 80rpx;
		overflow: hidden;
		margin-bottom: 80rpx;
		text-align: center;
	}

	.u-avatar-demo {
		width: 150rpx;
		height: 150rpx;
		border-radius: 100rpx;
	}
</style>